<?php

namespace getMembers;

class GetMembers{
	private $con;
	
	public function __construct(){
			
		$this->con = mysqli_connect("10.101.1.88", "167620_mz14316", "Asd33e5fg", "167620-benny");
	
		// Check connection
		if (mysqli_connect_errno())
		{
		echo "Failed to connect to MySQL: " . mysqli_connect_error();
		}	
	}
	
	//adds user to database
	public function addUser($user, $password){
		
			mysqli_query($this->con,"INSERT INTO users (Username, Password)
			VALUES ('$user', '$password')");
			mysqli_close($this->con);
	}
	
	//check username and password with database
	//@return bool
	public function checkMember($username, $password){

		$result = mysqli_query($this->con,"SELECT * FROM users");

		while($row = mysqli_fetch_array($result)){
			if($username == $row['Username'] && $password == $row['Password']){
				return TRUE;
			}
  		}
		return FALSE;
	}
}
